<template>
  <div id="app">
    <router-view @loginSuccess="handleLoginSuccess"></router-view>
  </div>
</template>

<script>
export default {
  methods: {
    handleLoginSuccess({ username,role, name }) {
      console.log('handleLoginSuccess:', username,role, name);
      const roleRouteMap = {
        admin: '/admin/Main',
        player: '/player/Main2',
        coach: '/coach/Main3'
      };
      const routePath = roleRouteMap[role];
      if (routePath) {
        console.log(`Redirecting to ${routePath}`);
        this.$router.push({ path: routePath, query: { username:username, role: role, name: name } });
      } else {
        console.error('Unknown role:', role);
      }
    }
  }
};
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
</style>
